
package com.thinkgsp.jxc.model;

import java.io.Serializable;
import java.math.BigDecimal;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.thinkgsp.util.XlsFieldAnnotation;
import com.thinkgsp.util.XlsValueType;

/**
 * 往来余额表类
 * @author evan
 *
 */
public class RpContactBalance extends BaseModel implements Serializable {

	private static final long serialVersionUID = 208759556758634823L;

	private Long id;
	private Integer direct;
	@XlsFieldAnnotation(ChsName="年份",MethodName="getFyear")
	private Integer fyear;
	@XlsFieldAnnotation(ChsName="期间",MethodName="getPeriod")
	private Integer period;
	private Integer custSuppId;
	private Integer deptId;
	private Integer empId;
	@XlsFieldAnnotation(ChsName="客户",MethodName="getCustomer",RefType=XlsValueType.RefClass)
	private Customer customer;
	@XlsFieldAnnotation(ChsName="期初余额",MethodName="getBeginAmount")
	private BigDecimal beginAmount = BigDecimal.ZERO;
	@XlsFieldAnnotation(ChsName="借方金额",MethodName="getDebitAmount")
	private BigDecimal debitAmount = BigDecimal.ZERO;
	@XlsFieldAnnotation(ChsName="贷方金额",MethodName="getCreditAmount")
	private BigDecimal creditAmount = BigDecimal.ZERO;
	@XlsFieldAnnotation(ChsName="期间余额",MethodName="getEndAmount")
	private BigDecimal endAmount = BigDecimal.ZERO;
	@XlsFieldAnnotation(ChsName="年度借方金额",MethodName="getYearDebitAmount")
	private BigDecimal yearDebitAmount = BigDecimal.ZERO;
	@XlsFieldAnnotation(ChsName="年度贷方金额",MethodName="getYearCreditAmount")
	private BigDecimal yearCreditAmount = BigDecimal.ZERO;
	
	
	private Dept dept;
	private Emp emp;
	
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
		this.custSuppId = customer.getCustomerId();
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
		this.deptId = dept.getDeptId();
	}

	public Emp getEmp() {
		return emp;
	}

	public void setEmp(Emp emp) {
		this.emp = emp;
		this.empId = emp.getEmpId();
	}

	/**
	 * ID
	 * @return
	 */
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * 借贷方向(1 : 借方 ; -1 : 贷方)
	 * @return
	 */
	public Integer getDirect() {
		return direct;
	}

	public void setDirect(Integer direct) {
		this.direct = direct;
	}

	/**
	 * 年份
	 * @return
	 */
	public Integer getFyear() {
		return fyear;
	}

	public void setFyear(Integer fyear) {
		this.fyear = fyear;
	}

	/**
	 * 期间
	 * @return
	 */
	public Integer getPeriod() {
		return period;
	}

	public void setPeriod(Integer period) {
		this.period = period;
	}

	/**
	 * 客户
	 * @return
	 */
	public Integer getCustSuppId() {
		return custSuppId;
	}

	public void setCustSuppId(Integer custSuppId) {
		this.custSuppId = custSuppId;
	}

	/**
	 * 部门
	 * @return
	 */
	public Integer getDeptId() {
		return deptId;
	}

	public void setDeptId(Integer deptId) {
		this.deptId = deptId;
	}

	/**
	 * 职员
	 * @return
	 */
	public Integer getEmpId() {
		return empId;
	}

	public void setEmpId(Integer empId) {
		this.empId = empId;
	}

	/**
	 * 期初余额
	 * @return
	 */
	public BigDecimal getBeginAmount() {
		return beginAmount;
	}

	public void setBeginAmount(BigDecimal beginAmount) {
		this.beginAmount = beginAmount;
	}

	/**
	 * 借方金额
	 * @return
	 */
	public BigDecimal getDebitAmount() {
		return debitAmount;
	}

	public void setDebitAmount(BigDecimal debitAmount) {
		this.debitAmount = debitAmount;
	}

	/**
	 * 贷方金额
	 * @return
	 */
	public BigDecimal getCreditAmount() {
		return creditAmount;
	}

	public void setCreditAmount(BigDecimal creditAmount) {
		this.creditAmount = creditAmount;
	}

	/**
	 * 期间余额
	 * @return
	 */
	public BigDecimal getEndAmount() {
		return endAmount;
	}

	public void setEndAmount(BigDecimal endAmount) {
		this.endAmount = endAmount;
	}

	/**
	 * 年度借方金额
	 * @return
	 */
	public BigDecimal getYearDebitAmount() {
		return yearDebitAmount;
	}

	public void setYearDebitAmount(BigDecimal yearDebitAmount) {
		this.yearDebitAmount = yearDebitAmount;
	}

	/**
	 * 年度贷方金额
	 * @return
	 */
	public BigDecimal getYearCreditAmount() {
		return yearCreditAmount;
	}

	public void setYearCreditAmount(BigDecimal yearCreditAmount) {
		this.yearCreditAmount = yearCreditAmount;
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#toString()
	 */
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("arpBillId",this.id)
		  .append("amount",this.custSuppId)
		  .append("checkAmount",this.fyear)
		  .append("checkAmount",this.period)
		  .append("checkAmount",this.direct)
		  .append("checkAmount",this.beginAmount)
		  .append("checkAmount",this.debitAmount)
		  .append("checkAmount",this.creditAmount)
		  .append("checkAmount",this.endAmount);
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof RpContactBalance)) {
			return false;
		}
		final RpContactBalance cb = (RpContactBalance)o;
		if(id != null) {
			return id.equals(cb.getId());
		} else {
			return cb.getId() == null;
		}
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#hashCode()
	 */
	@Override
	public int hashCode() {
		return (this.id != null ? this.id.hashCode() : 0);
	}

}
